package com.itheima.web;


import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: yg
 * @create 2025-02-04 - 20:56
 * @
 */
public class MyHttpServlet implements Servlet {

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
        //根据请求方式不同，进行分别处理
        HttpServletRequest request = (HttpServletRequest) req;
        //1.获取请求方式
        String method = request.getMethod();
        //2.判断

        if ("GET".equals(method)){
            doGet(req, resp);
        }else if("POST".equals(method)){
            doPost(req, resp);
        }
    }
    protected void doGet(ServletRequest req, ServletResponse resp){

    }
    protected void doPost(ServletRequest req, ServletResponse resp){

    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
